<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models;

use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;

/**
 * Class OaRecord
 *
 * @property int $id
 * @property int|null $p_id
 * @property int|null $level
 * @property int|null $oa_flow_id
 * @property int|null $worker_id
 * @property int|null $submit_id
 * @property int|null $branch_id
 * @property int|null $massage_change_id
 * @property string|null $content
 * @property string|null $remark
 * @property string|null $is_finally
 * @property string|null $is_pass
 * @property Carbon|null $create_time
 * @property Carbon|null $update_time
 * @property int|null $img1_id
 * @property int|null $img2_id
 * @property int|null $img3_id
 * @property int|null $finance_id
 *
 * @property MassageChangeRecord|null $massage_change_record
 * @property FamiliesMoneyRecord|null $families_money_record
 * @property Image|null $image
 * @property OaFlow|null $oa_flow
 * @property Worker|null $worker
 * @property Branch|null $branch
 *
 * @package App\Models
 */
class OaRecord extends Model
{
	protected $table = 'oa_record';

	protected $casts = [
		'p_id' => 'int',
		'level' => 'int',
		'oa_flow_id' => 'int',
		'worker_id' => 'int',
		'submit_id' => 'int',
		'branch_id' => 'int',
		'massage_change_id' => 'int',
		'img1_id' => 'int',
		'img2_id' => 'int',
		'img3_id' => 'int',
		'finance_id' => 'int'
	];

	protected $fillable = [
		'p_id',
		'level',
		'oa_flow_id',
		'worker_id',
		'submit_id',
		'branch_id',
		'massage_change_id',
		'content',
		'remark',
		'is_finally',
		'is_pass',
		'img1_id',
		'img2_id',
		'img3_id',
		'finance_id'
	];

    public function massage_change_record()
    {
        return $this->belongsTo(MassageChangeRecord::class, 'massage_change_id');
    }

    public function families_money_record()
    {
        return $this->belongsTo(FamiliesMoneyRecord::class, 'finance_id');
    }

    public function oa_flow()
    {
        return $this->belongsTo(OaFlow::class);
    }

    public function worker()
    {
        return $this->belongsTo(Worker::class, 'worker_id');
    }

    public function submit()
    {
        return $this->belongsTo(Worker::class, 'submit_id');
    }

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

    public function image1()
    {
        return $this->belongsTo(Image::class, 'img1_id');
    }

    public function image2()
    {
        return $this->belongsTo(Image::class, 'img2_id');
    }

    public function image3()
    {
        return $this->belongsTo(Image::class, 'img3_id');
    }

}
